import {UserInfo} from "@/type/userType";

const key: string = "userInfo"

export const getStorage = (): UserInfo => {
    try {
        return JSON.parse(localStorage.getItem(key) as any)
    } catch (error) {
        return {} as UserInfo
    }
}


export const setStorage = <T>(value: T) => {
    localStorage.setItem(key, JSON.stringify(value))
}


export const removeStorage = () => {
    localStorage.removeItem(key)
}


export const clearStorage = () => {
    localStorage.clear()
}
